package vip.george.p1768;

public class P1768 {

    public String mergeAlternately(String word1, String word2) {
        StringBuilder sb = new StringBuilder();
        int l1 = word1.length();
        int l2 = word2.length();
        for (int i = 0; i < Math.max(l1, l2); i++) {
            if (i < l1) {
                sb.append(word1.charAt(i));
            }
            if (i < l2) {
                sb.append(word2.charAt(i));
            }
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        P1768 p = new P1768();
        System.out.println(p.mergeAlternately("abc", "pqr"));
        System.out.println(p.mergeAlternately("ef", "pqrs"));
    }
}
